﻿using MediatR;
using T.Basic.API.Appliction.Command.OutsourcedUnitsCommand;
using T.Basic.Repository.BasicInterface;

namespace T.Basic.API.Appliction.CommandHandlers.OutsourcedUnitsHanders
{
    /// <summary>
    /// 删除外协单位（单删）
    /// </summary>
    public class OutsourcedUnitsDeleteCommandHander : IRequestHandler<OutsourcedUnitsDeleteCommand, int>
    {
        private readonly IOutsourcedUnitsRepository _outsourcedUnitsRepository;
        public OutsourcedUnitsDeleteCommandHander(IOutsourcedUnitsRepository outsourcedUnitsRepository)
        {
            _outsourcedUnitsRepository = outsourcedUnitsRepository;
        }
        public async Task<int> Handle(OutsourcedUnitsDeleteCommand request, CancellationToken cancellationToken)
        {
            var delout = await _outsourcedUnitsRepository.GetModelsAsync(request.OutsourcedUnitsId);
            delout.IsDeleted = true;
           
            return await _outsourcedUnitsRepository.UpdateAsync(delout);
        }
    }
}
